import path from 'path';
import { defineConfig } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';

// https://vitejs.dev/config/
async function configFun() {
  const UnoCSS = (await import('unocss/vite')).default;

  return defineConfig({
    plugins: [
      uni(),
      UnoCSS(),
      AutoImport({
        imports: ['vue', 'uni-app']
      }),
      Components({
        dirs: ['src/components'],
        dts: path.resolve(__dirname, 'components.d.ts')
      })
    ],
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src')
      }
    },
    server: {
      port: 2100,
      host: '0.0.0.0'
    },
    css: {
      preprocessorOptions: {
        scss: {
          additionalData: '@import "@/mt.scss"; @import "@/uni.scss";'
        }
      }
    }
  });
}
export default configFun;
